package main

import (
	"fmt"
	"math/rand"
	"time"
)

func insertSort(nums *[]int) {
	if nums == nil || len(*nums) == 0 {
		return
	}

	for i := 1; i < len(*nums); i++ {
		j := i - 1
		insertNode := (*nums)[i]
		for j >= 0 && insertNode < (*nums)[j] {
			(*nums)[j+1] = (*nums)[j]
			j--
		}

		(*nums)[j+1] = insertNode
	}
}

func main() {
	nums := make([]int, 100000)

	startTime := time.Now()

	for i := 0; i < 1; i++ {
		for i := 0; i < len(nums); i++ {
			nums[i] = rand.Intn(10000000)
		}

		insertSort(&nums)
	}

	endTime := time.Now()

	//fmt.Println(nums)
	fmt.Println("time: ", endTime.Sub(startTime))
}
